package com.example.springlist.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springlist.business.entity.Todos;
import org.apache.ibatis.annotations.*;

public interface TodosMapper extends BaseMapper<Todos> {

    @Delete("DELETE FROM todos WHERE id = #{id}")
    int deleteById(@Param("id") int id);

    @Delete("DELETE FROM todos where done = 1")
    int deleteAll();

    @Insert("insert into todos(title, done) values(#{title}, #{done});")
    int add(@Param("title") String title,  @Param("done") int done);

    @Update("update todos set done = #{done}")
    int selectAll(@Param("done") int done);

    @Update("update todos set done = #{done} where id = #{id}")
    int selectById(@Param("done") int done, @Param("id") int id);
}
